const request=require("request");

const TESTURL = require("./config/InUse").serverUrl;
function creat(){
    for(let i=0;i<500;i++){
        request({
            url:`http://localhost:${TESTURL}/?name=${i}&description=${i*1024}`,
            method:"put"
        },(err,response,body)=>{
            if(err){
                console.log(err);
            }else{
                console.log({"response":response.statue,"body":body});
            }
        })
    }
}

function deletetest(){
    for(let i=0;i<500;i++){
        request({
            url:`http://localhost:${TESTURL}/?name=${i}`,
            method:"delete"
        },(err,response,body)=>{
            if(err){
                console.log(err);
            }else{
                console.log({"response":response.data,"body":body});
            }
        })
    }
}
function updatetest(){
    for(let i=0;i<500;i++){
        let item=i+"i"
        request({
            url:`http://localhost:${TESTURL}/?name=${i}&newname=${item}`,
            method:"post"
        },(err,response,body)=>{
            if(err){
                console.log(err);
            }else{
                console.log({"response":response.data,"body":body});
            }
        })
    }
}
function gettest(){
    for(let i=0;i<500;i++){
        request({
            url:`http://localhost:${TESTURL}/?name=${i}&newname=${i}`,
            method:"get"
        },(err,response,body)=>{
            if(err){
                console.log(err);
            }else{
                console.log({"response":response.data,"body":body});
            }
        })
    }
}
deletetest()